package com.example.spring_aop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @className: AspectDemo2
 * @author: 芃
 * @description:
 * @date: 2024/12/30 13:36
 */
@Slf4j
@Component
@Aspect
@Order(1)
public class AspectDemo2 {

    @Around("com.example.spring_aop.aspect.AspectDemo.pt()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        long start = System.currentTimeMillis();//方法执行前的逻辑
        Object result = joinPoint.proceed();
        long end = System.currentTimeMillis();//方法执行后的逻辑
        log.info(joinPoint.toString() + "time cost: " + (end - start) + "ms+++++");
        return result;
    }
}
